﻿namespace WMS6.Web.Analytics
{
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.UserControls;

    public class BillingLoadDetailRptQuery : BasePage
    {
        protected Button btnSearch;
        protected DropDownList ddlCostType;
        protected DropDownList ddlCostTypeOper;
        protected DropDownList ddlDocTypeOper;
        protected DropDownList ddlDueFromTo;
        protected DropDownList ddlDueFromToOper;
        protected DropDownList ddlExternalOrderIDOper;
        protected DropDownList ddlForkliftDriver;
        protected DropDownList ddlIsHoliday;
        protected DropDownList ddlIsHolidayOper;
        protected DropDownList ddlIsPrint;
        protected DropDownList ddlIsPrintOper;
        protected DropDownList ddlOrderIDOper;
        protected DropDownList ddlOwnerID;
        protected DropDownList ddlWorkClass;
        protected HtmlForm F15640;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlHead Head1;
        protected HtmlImage imgForkliftDriver;
        protected HtmlImage imgOwnerID;
        protected HtmlImage imgWorkClass;
        protected Label lblCostType;
        protected Label lblDocType;
        protected Label lblDueFromTo;
        protected Label lblEndDate;
        protected Label lblExternalOrderID;
        protected Label lblForkliftDriver;
        protected Label lblIsHoliday;
        protected Label lblIsPrint;
        protected Label lblOrderID;
        protected Label lblOwnerID;
        protected Label lblQuery;
        protected Label lblStartDate;
        protected Label lblWorkClass;
        protected MultipleSelectControl MSCDocType;
        protected HtmlLink mycss;
        protected TextBox txtEndDate;
        protected TextBox txtExternalOrderID;
        protected TextBox txtForkliftDriver;
        protected TextBox txtOrderID;
        protected TextBox txtOwnerID;
        protected TextBox txtStartDate;
        protected TextBox txtWorkClass;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("BillingLoadDetailRptList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("BillingLoadDetailRptList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        private void LoadData()
        {
            base.InitQueryDDL(this.ddlOrderIDOper, 0);
            base.InitQueryDDL(this.ddlExternalOrderIDOper, 0);
            base.InitQueryDDL(this.ddlDocTypeOper, 0);
            base.InitQueryDDL(this.ddlCostTypeOper, 0);
            base.InitQueryDDL(this.ddlDueFromToOper, 0);
            base.InitQueryDDL(this.ddlIsHolidayOper, 0);
            base.InitQueryDDL(this.ddlOwnerID, 0);
            base.InitQueryDDL(this.ddlForkliftDriver, 0);
            base.InitQueryDDL(this.ddlWorkClass, 0);
            base.InitQueryDDL(this.ddlIsPrintOper, 0);
            this.ddlDocTypeOper.SelectedValue = "One Of";
            base.BindData2DDLBySysCode(this.MSCDocType, "BillingType");
            base.BindData2DDLBySysCode(this.ddlCostType, "CostType");
            base.BindData2DDLBySysCode(this.ddlDueFromTo, "DueFromTo");
            this.ddlCostType.Items.Insert(0, "");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadData();
            }
        }

        public string CostType
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlCostType.SelectedValue))
                {
                    return base.GetParamsString(this.ddlCostType.SelectedValue, this.ddlCostTypeOper.SelectedValue);
                }
                return "";
            }
        }

        public string DueFromTo
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlDueFromTo.SelectedValue))
                {
                    return base.GetParamsString(this.ddlDueFromTo.SelectedValue, this.ddlDueFromToOper.SelectedValue);
                }
                return "";
            }
        }

        public string EndDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtEndDate.Text.Trim()))
                {
                    return (Convert.ToDateTime(this.txtEndDate.Text).ToString("yyyy-MM-dd") + " 23:59:59");
                }
                return "";
            }
        }

        public string ExternalOrderID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtExternalOrderID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtExternalOrderID.Text.Trim(), this.ddlExternalOrderIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string ForkliftDriverID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtForkliftDriver.Text.Trim()))
                {
                    return base.GetParamsString(this.txtForkliftDriver.Text.Trim(), this.ddlForkliftDriver.SelectedValue);
                }
                return "";
            }
        }

        public string FromTo
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlDueFromTo.SelectedValue))
                {
                    return this.ddlDueFromTo.SelectedValue;
                }
                return "";
            }
        }

        public string IsHoliday
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlIsHoliday.SelectedValue))
                {
                    return base.GetParamsString(this.ddlIsHoliday.SelectedValue, this.ddlIsHolidayOper.SelectedValue);
                }
                return "";
            }
        }

        public string IsPrint
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlIsPrint.SelectedValue))
                {
                    return base.GetParamsString(this.ddlIsPrint.SelectedValue, this.ddlIsPrintOper.SelectedValue);
                }
                return "";
            }
        }

        public string OrderID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOrderID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOrderID.Text.Trim(), this.ddlOrderIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string OrderType
        {
            get
            {
                if (!string.IsNullOrEmpty(this.MSCDocType.ReturnValue))
                {
                    return base.GetParamsString(this.MSCDocType.ReturnValue, this.ddlDocTypeOper.SelectedValue);
                }
                return "";
            }
        }

        public string OwnerID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOwnerID.Text.Trim(), this.ddlOwnerID.SelectedValue);
                }
                return "";
            }
        }

        public string StartDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtStartDate.Text.Trim()))
                {
                    return (Convert.ToDateTime(this.txtStartDate.Text).ToString("yyyy-MM-dd") + " 00:00:00");
                }
                return "";
            }
        }

        public string WorkClass
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtWorkClass.Text.Trim()))
                {
                    return base.GetParamsString(this.txtWorkClass.Text.Trim(), this.ddlWorkClass.SelectedValue);
                }
                return "";
            }
        }
    }
}

